#include "add_a_ch.h"
#include "ui_add_a_ch.h"
#include <QDebug>
#include <QMessageBox>

ADD_A_CH::ADD_A_CH(QString str,QString sfreq,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ADD_A_CH)
{
    ui->setupUi(this);
    switch_language(str);
    language = str;
    freq = sfreq;
    //ui->encrypt->clear();

    init(str);

    connect(ui->power,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_power(QString)));
    connect(ui->Bandwidth,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_Bandwidth(QString)));
    connect(ui->rxctsstype,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_RXCTCSSType(QString)));
    connect(ui->rxctsscode,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_RXCTCSSCode(QString)));
    connect(ui->txctsstype,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_TXCTCSSType(QString)));
    connect(ui->txctsscode,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_TXCTCSSCode(QString)));
    //connect(ui->volume,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_volume(QString)));
    connect(ui->mute,SIGNAL(currentIndexChanged(QString)),this,SLOT(deal_combox_mute(QString)));
    //ui->volume->setCurrentIndex(7);
    ui->mute->setCurrentIndex(2);

    //ui->num->setText("1");
    //密钥默认为空
    //ui->key->setText("");
    //呼叫列表
    slist = "1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
    //ui->list->setText(slist);
    list = slist;

     name = ui->name->text();
     recvfreq = ui->recvfreq->text();
     sendfreq = ui->sendfreq->text();
     //id = ui->id->text();
     id = "0";
     power = ui->power->currentText();
     Bandwidth = ui->Bandwidth->currentText();
     RX_CTCSS_Type = ui->rxctsstype->currentText();
     ui->rxctsscode->insertItem(0,"0","111");
     RX_CTCSS_Code = "0";
     TX_CTCSS_Type = ui->txctsstype->currentText();
     ui->txctsscode->insertItem(0,"0","111");
     TX_CTCSS_Code = "0";
     //volume = ui->volume->currentText();
     volume = "0";
     mute = ui->mute->currentText();
}

void ADD_A_CH::init(QString language)
{
    if (language == "Chinese")
    {
        ui->power->insertItem(0,"高","111");
        ui->power->insertItem(1,"低","111");
        ui->power->setCurrentIndex(0);

        ui->Bandwidth->insertItem(0,"宽带","111");
        ui->Bandwidth->insertItem(1,"窄带","111");
        ui->Bandwidth->setCurrentIndex(0);

        ui->rxctsstype->insertItem(0,"载波","111");
        ui->rxctsstype->insertItem(1,"CTCSS","111");
        ui->rxctsstype->insertItem(2,"正向CDCSS","111");
        ui->rxctsstype->insertItem(3,"反向CDCSS","111");
        ui->rxctsstype->setCurrentIndex(0);

//        ui->rxctsscode->clear();

        ui->txctsstype->insertItem(0,"载波","111");
        ui->txctsstype->insertItem(1,"CTCSS","111");
        ui->txctsstype->insertItem(2,"正向CDCSS","111");
        ui->txctsstype->insertItem(3,"反向CDCSS","111");
        ui->txctsstype->setCurrentIndex(0);

        //ui->encrypt->insertItem(0,"关","111");
        //ui->encrypt->insertItem(1,"开","111");
        //ui->encrypt->setCurrentIndex(0);

//        ui->txctsscode->clear();

//        for(int i = 1; i <= 8; i++) {
//            QString str = QString("%1").arg(i);
//            ui->volume->insertItem(i-1,str,"111");
//        }
//        ui->volume->setCurrentIndex(7);

//        for(int i = 2; i <= 9; i++) {
//            QString str = QString("%1").arg(i);
//            ui->mute->insertItem(i-2,str,"111");
//        }
//        ui->volume->setCurrentIndex(3);

    }

    if (language == "English")
    {
        ui->power->insertItem(0,"High","111");
        ui->power->insertItem(1,"Low","111");
        ui->power->setCurrentIndex(0);

        ui->Bandwidth->insertItem(0,"Bandwidth","111");
        ui->Bandwidth->insertItem(1,"NarrowBand","111");
        ui->Bandwidth->setCurrentIndex(0);

        ui->rxctsstype->insertItem(0,"CarrierWave","111");
        ui->rxctsstype->insertItem(1,"CTCSS","111");
//        ui->rxctsstype->insertItem(2,"F_CDCSS","111");
//        ui->rxctsstype->insertItem(3,"B_CDCSS","111");
        ui->rxctsstype->insertItem(2,"CDCSS","111");
        ui->rxctsstype->insertItem(3,"CDCSS_Revert","111");
        ui->rxctsstype->setCurrentIndex(0);

//        ui->rxctsscode->clear();

        ui->txctsstype->insertItem(0,"CarrierWave","111");
        ui->txctsstype->insertItem(1,"CTCSS","111");
//        ui->txctsstype->insertItem(2,"F_CDCSS","111");
//        ui->txctsstype->insertItem(3,"B_CDCSS","111");
        ui->txctsstype->insertItem(2,"CDCSS","111");
        ui->txctsstype->insertItem(3,"CDCSS_Revert","111");
        ui->txctsstype->setCurrentIndex(0);

        //ui->encrypt->insertItem(0,"Close","111");
        //ui->encrypt->insertItem(1,"Open","111");
        //ui->encrypt->setCurrentIndex(0);
    }
    ui->recvfreq->setText(freq);
    ui->sendfreq->setText(freq);
}

ADD_A_CH::~ADD_A_CH()
{
    delete ui;
}

void ADD_A_CH::deal_combox_power(QString str)
{
    QString power = ui->power->currentText();
    qDebug() << "功率为" << power;
}
void ADD_A_CH::deal_combox_Bandwidth(QString str)
{
    QString power = ui->Bandwidth->currentText();
    qDebug() << "带宽" << power;
}
void ADD_A_CH::deal_combox_RXCTCSSType(QString str)
{
    //QString power = ui->rxctsstype->currentText();
    int index = ui->rxctsstype->currentIndex();
    qDebug() << "接收亚音类型" << power;
     ui->rxctsscode->clear();
    if (index == 0) {
        RX_CTCSS_Code = "0";
        ui->rxctsscode->insertItem(0,"0","111");
    }
    if (index == 1) { //CTCSS
        ui->rxctsscode->insertItem(0,"62.5","111");
        ui->rxctsscode->insertItem(1,"67.0","111");
        ui->rxctsscode->insertItem(2,"69.3","111");
        ui->rxctsscode->insertItem(3,"71.9","111");
        ui->rxctsscode->insertItem(4,"74.4","111");
        ui->rxctsscode->insertItem(5,"77.0","111");
        ui->rxctsscode->insertItem(6,"79.7","111");
        ui->rxctsscode->insertItem(7,"82.5","111");
        ui->rxctsscode->insertItem(8,"85.4","111");
        ui->rxctsscode->insertItem(9,"88.5","111");
        ui->rxctsscode->insertItem(10,"91.5","111");
        ui->rxctsscode->insertItem(11,"94.8","111");
        ui->rxctsscode->insertItem(12,"97.4","111");
        ui->rxctsscode->insertItem(13,"100.0","111");
        ui->rxctsscode->insertItem(14,"103.5","111");
        ui->rxctsscode->insertItem(15,"107.2","111");
        ui->rxctsscode->insertItem(16,"110.9","111");
        ui->rxctsscode->insertItem(17,"114.8","111");
        ui->rxctsscode->insertItem(18,"118.8","111");
        ui->rxctsscode->insertItem(19,"123.0","111");
        ui->rxctsscode->insertItem(20,"127.3","111");
        ui->rxctsscode->insertItem(21,"131.8","111");
        ui->rxctsscode->insertItem(22,"136.5","111");
        ui->rxctsscode->insertItem(23,"141.3","111");
        ui->rxctsscode->insertItem(24,"146.2","111");
        ui->rxctsscode->insertItem(25,"151.4","111");
        ui->rxctsscode->insertItem(26,"156.7","111");
        ui->rxctsscode->insertItem(27,"159.8","111");
        ui->rxctsscode->insertItem(28,"162.5","111");
        ui->rxctsscode->insertItem(29,"165.5","111");
        ui->rxctsscode->insertItem(30,"167.9","111");
        ui->rxctsscode->insertItem(31,"171.3","111");
        ui->rxctsscode->insertItem(32,"173.8","111");
        ui->rxctsscode->insertItem(33,"177.3","111");
        ui->rxctsscode->insertItem(34,"179.9","111");
        ui->rxctsscode->insertItem(35,"183.5","111");
        ui->rxctsscode->insertItem(36,"186.2","111");
        ui->rxctsscode->insertItem(37,"189.9","111");
        ui->rxctsscode->insertItem(38,"192.8","111");
        ui->rxctsscode->insertItem(39,"196.6","111");
        ui->rxctsscode->insertItem(40,"199.5","111");
        ui->rxctsscode->insertItem(41,"203.5","111");
        ui->rxctsscode->insertItem(42,"206.5","111");
        ui->rxctsscode->insertItem(43,"210.7","111");
        ui->rxctsscode->insertItem(44,"218.1","111");
        ui->rxctsscode->insertItem(45,"225.7","111");
        ui->rxctsscode->insertItem(46,"229.1","111");
        ui->rxctsscode->insertItem(47,"233.6","111");
        ui->rxctsscode->insertItem(48,"241.8","111");
        ui->rxctsscode->insertItem(49,"250.3","111");
        ui->rxctsscode->insertItem(50,"254.1","111");
        //for (int i = 0; i <= 50; i++)
        //   ui->rxctsscode->insertItem(i,QString("%1").arg(i),"111");
    }
    if ((index == 2) || (index == 3)) {
        ui->rxctsscode->insertItem(0,"023","111");
        ui->rxctsscode->insertItem(1,"025","111");
        ui->rxctsscode->insertItem(2,"026","111");
        ui->rxctsscode->insertItem(3,"031","111");
        ui->rxctsscode->insertItem(4,"032","111");
        ui->rxctsscode->insertItem(5,"043","111");
        ui->rxctsscode->insertItem(6,"047","111");
        ui->rxctsscode->insertItem(7,"051","111");
        ui->rxctsscode->insertItem(8,"054","111");
        ui->rxctsscode->insertItem(9,"065","111");
        ui->rxctsscode->insertItem(10,"071","111");
        ui->rxctsscode->insertItem(11,"072","111");
        ui->rxctsscode->insertItem(12,"073","111");
        ui->rxctsscode->insertItem(13,"074","111");
        ui->rxctsscode->insertItem(14,"114","111");
        ui->rxctsscode->insertItem(15,"115","111");
        ui->rxctsscode->insertItem(16,"116","111");
        ui->rxctsscode->insertItem(17,"125","111");
        ui->rxctsscode->insertItem(18,"131","111");
        ui->rxctsscode->insertItem(19,"132","111");
        ui->rxctsscode->insertItem(20,"134","111");
        ui->rxctsscode->insertItem(21,"143","111");
        ui->rxctsscode->insertItem(22,"152","111");
        ui->rxctsscode->insertItem(23,"155","111");
        ui->rxctsscode->insertItem(24,"156","111");
        ui->rxctsscode->insertItem(25,"162","111");
        ui->rxctsscode->insertItem(26,"165","111");
        ui->rxctsscode->insertItem(27,"172","111");
        ui->rxctsscode->insertItem(28,"174","111");
        ui->rxctsscode->insertItem(29,"205","111");
        ui->rxctsscode->insertItem(30,"223","111");
        ui->rxctsscode->insertItem(31,"226","111");
        ui->rxctsscode->insertItem(32,"243","111");
        ui->rxctsscode->insertItem(33,"244","111");
        ui->rxctsscode->insertItem(34,"245","111");
        ui->rxctsscode->insertItem(35,"251","111");
        ui->rxctsscode->insertItem(36,"261","111");
        ui->rxctsscode->insertItem(37,"263","111");
        ui->rxctsscode->insertItem(38,"265","111");
        ui->rxctsscode->insertItem(39,"271","111");
        ui->rxctsscode->insertItem(40,"306","111");
        ui->rxctsscode->insertItem(41,"311","111");
        ui->rxctsscode->insertItem(42,"315","111");
        ui->rxctsscode->insertItem(43,"331","111");
        ui->rxctsscode->insertItem(44,"343","111");
        ui->rxctsscode->insertItem(45,"346","111");
        ui->rxctsscode->insertItem(46,"351","111");
        ui->rxctsscode->insertItem(47,"364","111");
        ui->rxctsscode->insertItem(48,"365","111");
        ui->rxctsscode->insertItem(49,"371","111");
        ui->rxctsscode->insertItem(50,"411","111");
        ui->rxctsscode->insertItem(51,"412","111");
        ui->rxctsscode->insertItem(52,"413","111");
        ui->rxctsscode->insertItem(53,"423","111");
        ui->rxctsscode->insertItem(54,"431","111");
        ui->rxctsscode->insertItem(55,"432","111");
        ui->rxctsscode->insertItem(56,"445","111");
        ui->rxctsscode->insertItem(57,"464","111");
        ui->rxctsscode->insertItem(58,"465","111");
        ui->rxctsscode->insertItem(59,"466","111");
        ui->rxctsscode->insertItem(60,"503","111");
        ui->rxctsscode->insertItem(61,"506","111");
        ui->rxctsscode->insertItem(62,"516","111");
        ui->rxctsscode->insertItem(63,"532","111");
        ui->rxctsscode->insertItem(64,"546","111");
        ui->rxctsscode->insertItem(65,"565","111");
        ui->rxctsscode->insertItem(66,"606","111");
        ui->rxctsscode->insertItem(67,"612","111");
        ui->rxctsscode->insertItem(68,"624","111");
        ui->rxctsscode->insertItem(69,"627","111");
        ui->rxctsscode->insertItem(70,"631","111");
        ui->rxctsscode->insertItem(71,"632","111");
        ui->rxctsscode->insertItem(72,"654","111");
        ui->rxctsscode->insertItem(73,"662","111");
        ui->rxctsscode->insertItem(74,"664","111");
        ui->rxctsscode->insertItem(75,"703","111");
        ui->rxctsscode->insertItem(76,"712","111");
        ui->rxctsscode->insertItem(77,"723","111");
        ui->rxctsscode->insertItem(78,"731","111");
        ui->rxctsscode->insertItem(79,"732","111");
        ui->rxctsscode->insertItem(80,"734","111");
        ui->rxctsscode->insertItem(81,"743","111");
        ui->rxctsscode->insertItem(82,"754","111");
//        for (int i = 0; i <= 82; i++)
//           ui->rxctsscode->insertItem(i,QString("%1").arg(i),"111");
    }

}
void ADD_A_CH::deal_combox_RXCTCSSCode(QString str)
{
    QString power = ui->rxctsscode->currentText();
    qDebug() << "接收亚音码" << power;
}
void ADD_A_CH::deal_combox_TXCTCSSType(QString str)
{
    //QString power = ui->txctsstype->currentText();
    int index = ui->txctsstype->currentIndex();
    qDebug() << "发射亚音类型" << power;
     ui->txctsscode->clear();
    if (index == 0) {
        TX_CTCSS_Code = "0";
        ui->txctsscode->insertItem(0,"0","111");
    }
    if (index == 1) {
        ui->txctsscode->insertItem(0,"62.5","111");
        ui->txctsscode->insertItem(1,"67.0","111");
        ui->txctsscode->insertItem(2,"69.3","111");
        ui->txctsscode->insertItem(3,"71.9","111");
        ui->txctsscode->insertItem(4,"74.4","111");
        ui->txctsscode->insertItem(5,"77.0","111");
        ui->txctsscode->insertItem(6,"79.7","111");
        ui->txctsscode->insertItem(7,"82.5","111");
        ui->txctsscode->insertItem(8,"85.4","111");
        ui->txctsscode->insertItem(9,"88.5","111");
        ui->txctsscode->insertItem(10,"91.5","111");
        ui->txctsscode->insertItem(11,"94.8","111");
        ui->txctsscode->insertItem(12,"97.4","111");
        ui->txctsscode->insertItem(13,"100.0","111");
        ui->txctsscode->insertItem(14,"103.5","111");
        ui->txctsscode->insertItem(15,"107.2","111");
        ui->txctsscode->insertItem(16,"110.9","111");
        ui->txctsscode->insertItem(17,"114.8","111");
        ui->txctsscode->insertItem(18,"118.8","111");
        ui->txctsscode->insertItem(19,"123.0","111");
        ui->txctsscode->insertItem(20,"127.3","111");
        ui->txctsscode->insertItem(21,"131.8","111");
        ui->txctsscode->insertItem(22,"136.5","111");
        ui->txctsscode->insertItem(23,"141.3","111");
        ui->txctsscode->insertItem(24,"146.2","111");
        ui->txctsscode->insertItem(25,"151.4","111");
        ui->txctsscode->insertItem(26,"156.7","111");
        ui->txctsscode->insertItem(27,"159.8","111");
        ui->txctsscode->insertItem(28,"162.5","111");
        ui->txctsscode->insertItem(29,"165.5","111");
        ui->txctsscode->insertItem(30,"167.9","111");
        ui->txctsscode->insertItem(31,"171.3","111");
        ui->txctsscode->insertItem(32,"173.8","111");
        ui->txctsscode->insertItem(33,"177.3","111");
        ui->txctsscode->insertItem(34,"179.9","111");
        ui->txctsscode->insertItem(35,"183.5","111");
        ui->txctsscode->insertItem(36,"186.2","111");
        ui->txctsscode->insertItem(37,"189.9","111");
        ui->txctsscode->insertItem(38,"192.8","111");
        ui->txctsscode->insertItem(39,"196.6","111");
        ui->txctsscode->insertItem(40,"199.5","111");
        ui->txctsscode->insertItem(41,"203.5","111");
        ui->txctsscode->insertItem(42,"206.5","111");
        ui->txctsscode->insertItem(43,"210.7","111");
        ui->txctsscode->insertItem(44,"218.1","111");
        ui->txctsscode->insertItem(45,"225.7","111");
        ui->txctsscode->insertItem(46,"229.1","111");
        ui->txctsscode->insertItem(47,"233.6","111");
        ui->txctsscode->insertItem(48,"241.8","111");
        ui->txctsscode->insertItem(49,"250.3","111");
        ui->txctsscode->insertItem(50,"254.1","111");
//        for (int i = 0; i <= 50; i++)
//           ui->txctsscode->insertItem(i,QString("%1").arg(i),"111");
    }
    if ((index == 2) || (index == 3)) {
        ui->txctsscode->insertItem(0,"023","111");
        ui->txctsscode->insertItem(1,"025","111");
        ui->txctsscode->insertItem(2,"026","111");
        ui->txctsscode->insertItem(3,"031","111");
        ui->txctsscode->insertItem(4,"032","111");
        ui->txctsscode->insertItem(5,"043","111");
        ui->txctsscode->insertItem(6,"047","111");
        ui->txctsscode->insertItem(7,"051","111");
        ui->txctsscode->insertItem(8,"054","111");
        ui->txctsscode->insertItem(9,"065","111");
        ui->txctsscode->insertItem(10,"071","111");
        ui->txctsscode->insertItem(11,"072","111");
        ui->txctsscode->insertItem(12,"073","111");
        ui->txctsscode->insertItem(13,"074","111");
        ui->txctsscode->insertItem(14,"114","111");
        ui->txctsscode->insertItem(15,"115","111");
        ui->txctsscode->insertItem(16,"116","111");
        ui->txctsscode->insertItem(17,"125","111");
        ui->txctsscode->insertItem(18,"131","111");
        ui->txctsscode->insertItem(19,"132","111");
        ui->txctsscode->insertItem(20,"134","111");
        ui->txctsscode->insertItem(21,"143","111");
        ui->txctsscode->insertItem(22,"152","111");
        ui->txctsscode->insertItem(23,"155","111");
        ui->txctsscode->insertItem(24,"156","111");
        ui->txctsscode->insertItem(25,"162","111");
        ui->txctsscode->insertItem(26,"165","111");
        ui->txctsscode->insertItem(27,"172","111");
        ui->txctsscode->insertItem(28,"174","111");
        ui->txctsscode->insertItem(29,"205","111");
        ui->txctsscode->insertItem(30,"223","111");
        ui->txctsscode->insertItem(31,"226","111");
        ui->txctsscode->insertItem(32,"243","111");
        ui->txctsscode->insertItem(33,"244","111");
        ui->txctsscode->insertItem(34,"245","111");
        ui->txctsscode->insertItem(35,"251","111");
        ui->txctsscode->insertItem(36,"261","111");
        ui->txctsscode->insertItem(37,"263","111");
        ui->txctsscode->insertItem(38,"265","111");
        ui->txctsscode->insertItem(39,"271","111");
        ui->txctsscode->insertItem(40,"306","111");
        ui->txctsscode->insertItem(41,"311","111");
        ui->txctsscode->insertItem(42,"315","111");
        ui->txctsscode->insertItem(43,"331","111");
        ui->txctsscode->insertItem(44,"343","111");
        ui->txctsscode->insertItem(45,"346","111");
        ui->txctsscode->insertItem(46,"351","111");
        ui->txctsscode->insertItem(47,"364","111");
        ui->txctsscode->insertItem(48,"365","111");
        ui->txctsscode->insertItem(49,"371","111");
        ui->txctsscode->insertItem(50,"411","111");
        ui->txctsscode->insertItem(51,"412","111");
        ui->txctsscode->insertItem(52,"413","111");
        ui->txctsscode->insertItem(53,"423","111");
        ui->txctsscode->insertItem(54,"431","111");
        ui->txctsscode->insertItem(55,"432","111");
        ui->txctsscode->insertItem(56,"445","111");
        ui->txctsscode->insertItem(57,"464","111");
        ui->txctsscode->insertItem(58,"465","111");
        ui->txctsscode->insertItem(59,"466","111");
        ui->txctsscode->insertItem(60,"503","111");
        ui->txctsscode->insertItem(61,"506","111");
        ui->txctsscode->insertItem(62,"516","111");
        ui->txctsscode->insertItem(63,"532","111");
        ui->txctsscode->insertItem(64,"546","111");
        ui->txctsscode->insertItem(65,"565","111");
        ui->txctsscode->insertItem(66,"606","111");
        ui->txctsscode->insertItem(67,"612","111");
        ui->txctsscode->insertItem(68,"624","111");
        ui->txctsscode->insertItem(69,"627","111");
        ui->txctsscode->insertItem(70,"631","111");
        ui->txctsscode->insertItem(71,"632","111");
        ui->txctsscode->insertItem(72,"654","111");
        ui->txctsscode->insertItem(73,"662","111");
        ui->txctsscode->insertItem(74,"664","111");
        ui->txctsscode->insertItem(75,"703","111");
        ui->txctsscode->insertItem(76,"712","111");
        ui->txctsscode->insertItem(77,"723","111");
        ui->txctsscode->insertItem(78,"731","111");
        ui->txctsscode->insertItem(79,"732","111");
        ui->txctsscode->insertItem(80,"734","111");
        ui->txctsscode->insertItem(81,"743","111");
        ui->txctsscode->insertItem(82,"754","111");
//        for (int i = 0; i <= 82; i++)
//           ui->txctsscode->insertItem(i,QString("%1").arg(i),"111");
    }
}
void ADD_A_CH::deal_combox_TXCTCSSCode(QString str)
{
    QString power = ui->txctsscode->currentText();
    qDebug() << "发射亚音码" << power;
}
void ADD_A_CH::deal_combox_volume(QString str)
{
    //QString power = ui->volume->currentText();
    //qDebug() << "音量" << power;
}
void ADD_A_CH::deal_combox_mute(QString str)
{
    QString power = ui->mute->currentText();
    qDebug() << "静噪" << power;
}

void ADD_A_CH::on_pushButton_clicked()
{
    if (ui->name->text().isEmpty() ||
        ui->recvfreq->text().isEmpty() ||
        ui->sendfreq->text().isEmpty()) {
        if (language == "English")
            QMessageBox::warning(NULL, "prompt", "Please improve the data", "OK");
        if (language == "Chinese")
            QMessageBox::warning(NULL, "提示", "请完善数据", "确定");

        return;
    }

    if (ui->sendfreq->text().size() > 10) {
        if (language == "English")
            QMessageBox::warning(NULL, "prompt", "[TX Freq]The input length cannot exceed 9 characters", "OK");
        if (language == "Chinese")
            QMessageBox::warning(NULL, "提示", "[TX Freq]输入内容不能超过9个字符", "确定");
        return;
    }

    if (ui->recvfreq->text().size() > 10) {
        if (language == "English")
            QMessageBox::warning(NULL, "prompt", "[RF Freq]The input length cannot exceed 9 characters", "OK");
        if (language == "Chinese")
            QMessageBox::warning(NULL, "提示", "[RF Freq]输入内容不能超过9个字符", "确定");
        return;
    }

    name = ui->name->text();
    recvfreq = ui->recvfreq->text();
    sendfreq = ui->sendfreq->text();
    //id = ui->id->text();
    id = "0";
    power = ui->power->currentText();
    Bandwidth = ui->Bandwidth->currentText();
    RX_CTCSS_Type = ui->rxctsstype->currentText();
    RX_CTCSS_Code = ui->rxctsscode->currentText();
    TX_CTCSS_Type = ui->txctsstype->currentText();
    TX_CTCSS_Code = ui->txctsscode->currentText();
    //volume = ui->volume->currentText();
    volume = "0";
    mute = ui->mute->currentText();

    num = "";
    //list = ui->list->text();
    list = slist;
    key = "";
    lencrypt = "";

    QString str = QString("%1#%2#%3#%4#%5#%6#%7#%8#%9#%10#%11#%12#%13#%14#%15#%16").arg(name).arg(recvfreq).arg(sendfreq).arg(id)
            .arg(power).arg(Bandwidth).arg(RX_CTCSS_Type).arg(RX_CTCSS_Code).arg(TX_CTCSS_Type).arg(TX_CTCSS_Code).arg(volume).arg(mute)
            .arg(num).arg(list).arg(key).arg(lencrypt);
    emit send_str(str);
    this->close();
}

void ADD_A_CH::switch_language(QString language)
{
    if (language == "Chinese") {
        ui->lname->setText("信道名称");
        ui->lrecvfreq->setText("接收频率");
        ui->lsendfreq->setText("发射频率");
        //ui->lid->setText("本地ID");
        ui->lpower->setText("功率");
        ui->lcolorcode->setText("带宽");
        ui->lmode->setText("接收亚音类型");
        ui->lcall->setText("接收亚音码");
        ui->loutput->setText("发射亚音类型");
        ui->linput->setText("发射亚音码");
        //ui->lvolume->setText("音量");
        ui->lgain->setText("静噪");
        //ui->lid->setText("本地ID");
        //ui->lnum->setText("联系人号码");
        //ui->llist->setText("组呼列表");
        //ui->lkey->setText("密钥");
        //ui->lencrypt->setText("加密");
        //ui->pushButton->setText("确定");
        //ui->pushButton_2->setText("点击修改");
    }

    if (language == "English") {
        ui->lname->setText("Channel Name");
        ui->lrecvfreq->setText("RF Freq");
        ui->lsendfreq->setText("TX Freq");
        //ui->lid->setText("Local ID");
        ui->lpower->setText("Power");
        ui->lcolorcode->setText("Bandwidth");
        ui->lmode->setText("RX CTCSS Type");
        ui->lcall->setText("RX CTCSS Code");
        ui->loutput->setText("TX CTCSS Type");
        ui->linput->setText("TX CTCSS Code");
        //ui->lvolume->setText("Volume");
        ui->lgain->setText("SQL Level");
        //ui->lnum->setText("Contact Num");
        //ui->llist->setText("Group List");
        //ui->lkey->setText("Encrypt Key");
        //ui->lencrypt->setText("Encrypt");
        ui->pushButton->setText("Enter");
        //ui->pushButton_2->setText("Click Edit");
    }
}

void ADD_A_CH::deal_group_list(QString str)
{
    slist = str;
}

void ADD_A_CH::on_pushButton_2_clicked()
{
    grouplist *glist = new grouplist(slist);
    connect(glist,SIGNAL(send_str(QString)),this,SLOT(deal_group_list(QString)));
    glist->exec();
}

void ADD_A_CH::setFreq(QString str)
{
    freq = str;
}
